home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / GENetReleaseƒ / GEDemo / Meter.c < prev    next >
Text File  |  1994-03-07  |  1KB  |  50 lines

  1. /*
  2.     Meter.c
  3.     
  4.     A "meter" type Graphic Element
  5.     
  6.     Copyright 1993 by Al Evans. All rights reserved.
  7.     
  8.     11/5/93
  9. */
  10.  
  11. #include "Meter.h"
  12.  
  13. /*
  14.     Look at the meter's PICT resources to see how it works. The basic idea is that
  15.     the meter "bezel" has an opening 10 X 100 pixels for the indicator.
  16.     The indicator is 110 X 100 pixels in size. It is pure white for the top 10
  17.     pixels of its height. Below that, it is divided diagonally into red and white
  18.     areas. This indicator is scrolled up and down behind the bezel to give a
  19.     reading between 0 and 100&.
  20. */
  21.  
  22. Boolean LoadUsageMeterScene(GEWorldPtr world)
  23. {
  24.     GrafElPtr        meterBkg, thisElement;
  25.     
  26.     //Get meter bkg picture
  27.     meterBkg = NewBasicPICT(world, meterBkgID, meterPlane, rMeterBkg,
  28.                                 transparent, meterLeft, meterTop);
  29.     if (meterBkg == nil) return false;
  30.     
  31.     //Get Indicator picture
  32.     thisElement = NewScrollingGraphic(world, meterIndID, indPlane, rMeterInd,
  33.                                 srcCopy, indLeft, indTop);
  34.     if (thisElement == nil) return false;
  35.     
  36.     //Show only top 10 pixels of indicator
  37.     thisElement->animationRect.bottom = thisElement->animationRect.top + 10;
  38.     //Connect indicator to bkg
  39.     meterBkg->slaveGrafEl = thisElement;
  40.     return true;
  41. }
  42.  
  43. pascal void SetMeterReading(GEWorldPtr world, short percent)
  44. {
  45.     if (percent < 0) percent = 0;
  46.     if (percent > 100) percent = 100;
  47.     
  48.     SetScroll(world, meterIndID, 0, percent);
  49. }
  50.